package com.artPreter.utils;

import com.artPreter.pojo.ArtType;

import java.util.ArrayList;
import java.util.List;

public class ExchageArtTypeUtils {

    public static List<String> exchangeArtType(String str, List<ArtType> artTypeList){
        List<String> result = new ArrayList<>();
        if(str==null||"".equals(str)){
            return result;
        }
        String[] split = str.split("\\|");
        for (int i = 0; i < split.length; i++) {
            if(split[i]!=null&&!"".equals(split[i])){
                for (ArtType artType : artTypeList) {
                    if(artType.getTypeId().equals(split[i])){
                        result.add(artType.getName());
                    }
                }
            }
        }
        return result;
    }

    public static List<ArtType> exchangeArtTypeList(List<ArtType> nowList, List<ArtType> allList){
        List<ArtType> result = new ArrayList<>();
        for (int i = 0; i < nowList.size(); i++) {
            for (int j = 0; j < allList.size(); j++) {
                if(nowList.get(i).getTypeId().equals(allList.get(j).getTypeId())){
                    result.add(allList.get(j));
                }
            }
        }
        return result;
    }

    public static String exchangeArtTypeId(Integer id, List<ArtType> allList){
        String result = null;
        for (int i = 0; i < allList.size(); i++) {
            if(allList.get(i).getId().equals(id)){
                result = allList.get(i).getTypeId();
            }
        }
        return result;
    }
}
